<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>文章列表</title>
<link rel="stylesheet" href="${base}/images/contentImage/main.css" />
<script type="text/javascript" src="${base}/js/jquery-1.8.0.min.js"></script>
<script type="text/javascript" src="${base}/js/lhgdialog/lhgdialog.min.js"></script>
<script type="text/javascript" src="${base}/js/My97DatePicker4_8/WdatePicker.js"></script>
<script>
var base = '${base}';
function updateContent(id){
	 var url = "url:"+"${base}/content/admin/editContent.htm?contentId="+id+"&channelId=${channelId!}";
     $.dialog({
		lock: true,
		title:"修改文章",
		content: url,
		cancelVal: '取消',
		width:'770px',
		height:'440px',
	    cancel: function(){ //请求成功后处理函数。 
	    		$.dialog.tips('数据刷新中...',600,'loading.gif');
	    		refreshIframe();
		},
		button: [
		         {name: '保存',callback:function(){this.content.saveContent();return false;}}
	         ]
	});
}

function addContent(){
	 var url = "url:"+"${base}/content/admin/addContent.htm?channelId=${channelId!}";
    $.dialog({
		lock: true,
		title:"新增文章",
		content: url,
		cancelVal: '取消',
		width:'770px',
		height:'440px',
	    cancel: function(){ //请求成功后处理函数。 
	    		$.dialog.tips('数据刷新中...',600,'loading.gif');
	    		refreshIframe();
		},
		button: [
		         {name: '保存',callback:function(){this.content.saveContent();return false;}}
	         ]
	});
}

function getCheckBox(){
	 
    var ids="";
    $("input[name='ids']:checked").each(function(){  
             ids += $(this).val()+",";
     });
    if (ids.length > 0 ) ids = ids.substring(0, ids.length-1);      
	  return ids;

}

function delContent(id){
	if(id==null){
		if(getCheckBox()==""){
			$.dialog.alert("请选择至少一个多选框！");
			return;
		}
		$.dialog.confirm('是否确定删除?',function(){
			$.dialog.tips('文章删除中...',999999,'loading.gif');
			$.ajax({
 				type: 'POST',
 				dataType : "json",
 				data:{"contentIdStr":getCheckBox(),"channelId": ${channelId!}},
 				url: base+"/content/admin/deleteContent.htm",
 				error: function () {//请求失败处理函数
 					$.dialog.alert('请求失败！');
 				
 				},
 				success:function(data){ //请求成功后处理函数。 
 					$.dialog.alert(data.result,function(){
 						refreshIframe();
 					});
 				}
 			});
		},function(){},this);

	}else{
		$.dialog.confirm('是否确定删除?',function(){
			$.dialog.tips('文章删除中...',999999,'loading.gif');
			$.ajax({
 				type: 'POST',
 				dataType : "json",
 				data:{"contentId":id,"channelId": ${channelId!}},
 				url: base+"/content/admin/deleteContent.htm",
 				error: function () {//请求失败处理函数
 					$.dialog.alert('请求失败！');
 				
 				},
 				success:function(data){ //请求成功后处理函数。 
 					$.dialog.alert(data.result,function(){
 						refreshIframe();
 					});
 					
 				}
 			});
		},function(){},this);

	}
}
function refreshIframe(){
	$("#tableForm").submit();
}
</script>



</head>

<body>

<form action="${base!}/content/admin/list.htm" method="post" id = "tableForm" >
<input type="hidden"  name="channelId" value="${channelId!}"   />
<div class="titbg01">
<strong class="fl">内容列表</strong>

		<a  href="#" id="del_button" onclick="delContent()"  class="fr"><img border="0" align="absmiddle" src="${base}/images/contentImage/delForCh.gif">&nbsp;删除</a>
		<a  href="#" id="add_button" onclick="addContent()"  class="fr"><img border="0" align="absmiddle" src="${base}/images/contentImage/addForCh.gif">&nbsp;新增</a>

</div>

<div class="titb border_all"  style="width:98%;margin:5px auto">
<div>
&nbsp;&nbsp;标题: <input type="text"  class="w80"name="title" value="${content.title!}" id="title"  />&nbsp;

	文章类型:<select name="contentType" value="type" >
        <option value = ""   >--所有类型--</option>
        <option value = "1"  <#if content??&&content.contentType==1>  selected="selected"</#if> >--普通--</option>		
        <option value = "2"  <#if content??&&content.contentType==2>  selected="selected"</#if> >--图文--</option>	

    </select>&nbsp;
    排序:<select name="queryOrderBy"  value="queryOrderBy" >
        <option  value="1" <#if queryOrderBy==1> selected="selected"</#if> >发布时间降</option>
        <option  value="2"  <#if queryOrderBy==2> selected="selected"</#if>  >发布时间升</option>
        <option value="3"  <#if queryOrderBy==3> selected="selected"</#if>  >优先级降序</option>
        <option value="4"  <#if queryOrderBy==4> selected="selected"</#if>  >优先级降升</option>
     </select>&nbsp;
   文章的发布时间：<input type="text" class="w80" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss', maxDate:'#F{$dp.$D(\'endTime\')}'})" <#if  beginTime??> value="${(beginTime?string('yyyy-MM-dd HH:mm:ss'))!}"</#if> name="beginTime" id="beginTime" />
   至<input type="text" class="w80" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss', minDate:'#F{$dp.$D(\'beginTime\')}'})"  <#if endTime??>  value="${endTime?string('yyyy-MM-dd HH:mm:ss')}"</#if>  name="endTime" id = "endTime"/>

&nbsp;&nbsp;<input type="submit" value="查询" />
</div>
</div>



<table border="0" cellspacing="1" cellpadding="0" class="w100" style="border-top:1px solid #ccc;">

  <tr class="trtit" align="center">
    <td width="28" align="center" ><img src="${base}/images/contentImage/down.png"></td>
    <td class="border_b_r" width="28" align="center"><input type="checkbox" onClick="chooseAll(this.checked)" /></td>
    <td class="border_b_r" width="30">ID</td>
    <td class="border_b_r" width="280">标题</td>
    <td class="border_b_r">类型</td>
    <td class="border_b_r">优先级</td>
    <td class="border_b_r">发布时间</td>
    <td class="border_t_b" width="170">操作</td>
    
  </tr>
<#if pagination??> 
	<#if pagination.list??>
		<#list pagination.list as content>
		
		<tr align="center">
			<td align="center" class="rowIdx">&nbsp;</td>
    		<td class="border_b_r" align="center"><input type="checkbox" name='ids' value='${content.contentId}'/></td>
    		<td class="border_b_r">${content.contentId}</td>
			<td class="border_b_r">${content.title}</td>
		    <td class="border_b_r">
				<#if content.contentType==2>
					图文
				<#else>
				         普通
				</#if>
			</td>
			<td class="border_b_r">${content.priority!'0'}</td>
			<td class="border_b_r">${(content.createDate?string('yyyy-MM-dd HH:mm:ss'))!}</td>
			<td class="border_b_r">查看&nbsp;|&nbsp;	
			    <a href="javascript: updateContent(${content.contentId});">修改</a>
			    &nbsp;|&nbsp;
			    
			     <a href="javascript: delContent(${content.contentId});">删除</a>
			    </td>
		</#list>
    </#if>
 </#if>
</table>
<#include "${base}/server/content/pagination.html"/>


</form>

</body>
</html>
